var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
export function uuid(len: number, radix ? : number) {
    var chars = CHARS,
        uuid = [],
        rnd = Math.random;
    radix = radix || chars.length;
    if (len) {
        for (var i = 0; i < len; i++) uuid[i] = chars[0 | rnd() * radix];
    } else {
        var r;
        uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
        uuid[14] = '4';
        for (var i = 0; i < 36; i++) {
            if (!uuid[i]) {
                r = 0 | rnd() * 16;
                uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
            }
        }
    }
    return uuid.join('');
};


export function timestamp(){
    return (new Date()).valueOf()
}

export function md5(){
    
}



export class JSONResponse{
    static success(data:any,msg="success"){
        return {
            code:200,
            msg,
            data
        }
    }

    static error(err:any,msg="error"){
        return {
            code:500,
            msg:err.message ||msg,
            data:err
        }
    }

    static notfound(){
        return {
            code:404,
            msg:'请求路径不存在',
            data:null
        }
    }
}